﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using DongDong.Common;

/// <summary>
///Base 的摘要说明
/// </summary>
public class Base : System.Web.UI.Page
{
    /// <summary>
    /// 页面初始化http://localhost:3976/GRZX/LeftNava.aspx
    /// </summary>
    /// <param name="sender">对象</param>
    /// <param name="e">事件</param>
    protected void Page_Init(object sender, EventArgs e)
    {

        // 如果Session失效，返回到登陆页面
        // 修改记录：04
        if (Client.GetCurrent() == null)
        {
            //修改记录:03  修改日期: 2011-08-10 修改人: 刘丽利 活动号:612002196150  开始
            //string url = Page.Request.Url.ToString();
            //Session["URL"] = url;
            //Server.Transfer("~/Admin/AdminLogin.aspx");
            ////修改记录:03  修改日期: 2011-08-10 修改人: 刘丽利 活动号:612002196150  结束
            //Response.End();
        }
    }
    /// <summary>
    /// 获取市区json（Type=1返回市2=返回区）
    /// </summary>
    /// <param name="listCity">市</param>
    /// <param name="listCity">区</param>
    /// <param name="listCity">类型</param>
    public string DataTableJson(List<S_City> listCity, List<S_District> listDistrict, int Type)
    {
        StringBuilder jsonBuilder = new StringBuilder();
        jsonBuilder.Append("[");
        if (Type == 1)
        {
            foreach (S_City dr in listCity)
            {
                jsonBuilder.Append("{");
                jsonBuilder.Append("\"");
                jsonBuilder.Append("text");
                jsonBuilder.Append("\":\"");
                jsonBuilder.Append(dr.CityName);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append("value");
                jsonBuilder.Append("\":\"");
                jsonBuilder.Append(dr.CityID);
                jsonBuilder.Append("\"");
                jsonBuilder.Append("},");
            }
        }
        else
        {
            foreach (S_District dr in listDistrict)
            {
                jsonBuilder.Append("{");
                jsonBuilder.Append("\"");
                jsonBuilder.Append("text");
                jsonBuilder.Append("\":\"");
                jsonBuilder.Append(dr.DistrictName);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append("value");
                jsonBuilder.Append("\":\"");
                jsonBuilder.Append(dr.DistrictID);
                jsonBuilder.Append("\"");
                jsonBuilder.Append("},");
            }
        }
        if (jsonBuilder.Length != 0)
            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
        jsonBuilder.Append("]");
        return jsonBuilder.ToString();
    }
    public void SetMeta(string pageTitle, string keywords, string description)
    {
        Page.Title = pageTitle;
        if (keywords == null)
            keywords = "";

        if (description == null)
            description = "";

        Misc.SetMetaValues(this.Page.Header, "Keywords", keywords);
        Misc.SetMetaValues(this.Page.Header, "Description", description);
    }
    public enum navasort { 我是学员 = 1, 教学中心 = 2, 学付宝平台 = 3, 账号安全管理 = 4 }
}